<template>
		<u-overlay :show="_showPost" @click="_showPost = false">
				<view style="width: 650rpx;margin: 10px auto">
					<job-poster v-if="_showPost" :qrcode-text="pageUrl(`/pages/job/user/job-details/job-details?id=${currentTask.id}`)" @save="_showPost = false" :task="currentTask"></job-poster>
				</view>
		</u-overlay>
		
		<jobActions v-model="_showActions" :currentTask="currentTask"></jobActions>
		
		<u-action-sheet @select="onPromotionSelected" :actions="[
			{
				name:'海报推广',
				color:'#ffaa7f',
				fontSize:'20',
				type:'poster'
			},
			{
				name: '文本推文',
				type:'text'
			},
			{
				name: '详情二维码',
				type:'text'
			},
			{
				name: '报名链接',
				type:'link'
			},
			{
				name: '报名二维码',
				type:'qrcode'
			}
		]" title="推广方式" :show="_showPromotionActions" @close="_showPromotionActions=false" :round="10">
			
		</u-action-sheet>
		
		<u-modal :show="showPromotionText"  title="招聘推广文本" confirm-text="复制文本"
			@confirm="onCopyTextConfirm"
		>
				<view class="slot-content">
					<rich-text :nodes="promotionText"></rich-text>
				</view>
		</u-modal>
</template>

<script>
	import jobPoster from '@/components/posters/lime-painter.vue'
	import jobActions from './job-actions.vue'
	
	export default {
		name:"task-promotion",
		components:{
			jobPoster,
			jobActions
		},
		props:{
			currentTask:{
				type:Object,
				default:null
			},
			showPost:{
				type:Boolean,
				default:false
			},
			showActions:{
				type:Boolean,
				default:false
			},
			showPromotionActions:{
				type:Boolean,
				default:false
			}
		},
		data() {
			return {
				_showPromotionActions:false,
				showPromotionText:false,
				_showActions:false,
				_showPost:false,
				promotionText:`
					黄埔愉景湾酒店帮工<br/>
					2023-10-29 周四<br/>
					广州市黄埔区御景广场地铁A口<br/>
					中餐厅服务员: 中午12:00-21:30 16元/小时/日结<br/>
					女生 170以上 提前30分钟到场 有节日 高温补贴 提供晚餐<br/>
					有意向的同学联系微信号:qiyi245784<br/>
					点击报名链接: weixin://7dnN8s456Jy/e8w<br/>
				`
			};
		},
		watch:{
			showPost(value){
				this._showPost = value
			},
			showActions(value){
				this._showActions = value
			},
			showPromotionActions(value){
				console.log('showPromotionActions' + value)
				this._showPromotionActions = value
			},
			_showPost(value){
				this.$emit('update:showPost',value)
			},
			_showActions(value){
				this.$emit('update:showActions',value)
			},
			_showPromotionActions(value){
				this.$emit('update:showPromotionActions',value)
			},
			currentTask(value){
				console.log(value)
			}
		},
		methods:{
			showPromotion(task) {
				this._showPromotionActions = true
				this.taskSelected = task
				//this.onInvite(task)
			},
			onChannelPromotion() {
				uni.navigateTo({
					url:'/pages/job/publish/job-offices/job-offices'
				})
			},
			onPromotionSelected(e){
				console.log(e)
				
				if(e.type == 'poster')
				{
					this.onInvite(this.currentTask)
					//this.$emit('onPromotionSelected')
				}else if(e.type == 'text')
				{
					this.showPromotionText = true
				}
			},
			async onCopyTextConfirm(){
				// if(navigator.clipboard.writeText)
				// {
				// 	navigator.clipboard.writeText(this.promotionText)
				
				// 	uni.showToast({
				// 		title:'已复制到剪贴板'
				// 	})
				// }
				
				await uni.setClipboardData({
					data:'黄埔愉景湾酒店帮工\n2023-10-29 周四\n广州市黄埔区御景广场地铁A口\n中餐厅服务员: 中午12:00-21:30 16元/小时/日结\n女生 170以上 提前30分钟到场 有节日 高温补贴 提供晚餐\n有意向的同学联系微信号:qiyi245784\n点击报名链接: weixin://7dnN8s456Jy/e8w\n',
					showToast:true
				})
				
				this.showPromotionText = false
			},
			onInvite(task){
				// this.currentTask = task
				this._showPost = true
			},
		}
		
	}
</script>

<style>

</style>